package cn.edu.sgu.www.pms;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.context.annotation.Bean;

import javax.servlet.ServletContext;

/**
 * @author 沐雨橙风ιε
 * @version 1.0
 */
@SpringBootApplication
public class Pms {

    static final Logger logger = LoggerFactory.getLogger(Pms.class);

    public static void main(String[] args) {
        if (logger.isDebugEnabled()) {
            logger.debug("启动权限平台...");
        }

        SpringApplication.run(Pms.class, args);
    }

    /**
     * 设置SESSION_ID
     * @return ServletContextInitializer
     */
    @Bean
    public ServletContextInitializer servletContextInitializer() {
        return new ServletContextInitializer() {
            @Override
            public void onStartup(ServletContext servletContext) {
                servletContext.getSessionCookieConfig().setName("PMS_JSESSIONID");
            }
        };
    }

}